<?php

class TestController extends BaseController {
    public $data = array();

    public function __construct(){
        $this->data['user_agent'] = $this->getUserAgent();
        if( Session::has('user_id') ){
            $this->data['is_login'] = 1;
            $this->data['user_id']  = Session::get('user_id');
            $this->data['icon']     = Session::get('icon');
            $this->data['name']     = Session::get('name');
            $this->data['number']   = Session::get('number');
        }else{
            $this->data['user_id']      = 0;
            $this->data['lib_login']    = 0;
        }
    }

    public function index(){
        $this->data['description'] = "测试";

        return View::make("index" , $this->data);
    }

    public function search_list(){
        $this->data['description'] = "测试";
        return View::make("search_list" , $this->data);
    }

    public function search_detail(){
        $this->data['description'] = "测试";
        return View::make("search_detail" , $this->data);
    }

    public function user_center(){
        $this->data['description'] = "测试";
        return View::make("user_center" , $this->data);
    }

    public function blike(){
        $this->data['description'] = "测试";
        return View::make("blike" , $this->data);
    }
     public function bhistory(){
        $this->data['description'] = "测试";
        return View::make("bhistory" , $this->data);
    }
    public function bnow(){
        $this->data['description'] = "测试";
        return View::make("bnow" , $this->data);
    }


    public function getUserAgent(){
        if( strpos($_SERVER['HTTP_USER_AGENT'], 'PTime.IOSWeb') !== false):
            $userAgent = "ptimeios";
        elseif( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false):
            $userAgent = "wechat";
        elseif( strpos($_SERVER['HTTP_USER_AGENT'], 'PTime.AndroidWeb') !== false):
            $userAgent = "ptimeandroid";
        elseif( strpos($_SERVER['HTTP_USER_AGENT'], 'MQQBrowser')!== false):
            $userAgent = "mqq";
        else:
            $userAgent = "other";
        endif;
        return $userAgent;
    }
}
